package com.binarysoft.service.type;

import java.util.Collection;

import common.framework.dsb.DynamicService;

/**
 * @author David
 * 
 */
public interface TypeService extends DynamicService {
	String ROOT_TYPE_ID = "object";
	String ROOT_TYPE_NAME = "Object";

	/**
	 * 判断typeA 是否属入typeB 或者说判断typeA 是否继承自typeB(注意: type a == type b, 应该返回true)
	 * 
	 * @param typeA
	 * @param typeB
	 * @return
	 */
	boolean isatype(String typeA, String typeB);

	/**
	 * 判断typeA 和 typeB 是否具备直系家族关系(即判断给定的两个type是否在同一条继承线上), 例如NE->CPU,
	 * NE->Port->Ethernet-csmacd这样的继承关系中 CPU和Port就不是直系家族,
	 * Ethernet-csmacd和Port就是直系家族, Port和NE就是直系家族 .(注意: type a == type b 时,
	 * 应该返回true)
	 * 
	 * @param typeA
	 * @param TypeB
	 * @return
	 */
	boolean isLinealFamily(String typeA, String typeB);

	/**
	 * Add a type
	 * 
	 * @param typeID
	 * @param typeName
	 * @param typeDesc
	 * @param parentTypeID
	 * @throws Exception
	 */
	void addType(String typeID, String typeName, String typeDesc, String parentTypeID) throws Exception;

	void addType(Type type) throws Exception;

	/**
	 * type with typeID and all it's sub-types will be deleted recursively
	 * 
	 * @param typeID
	 * @throws Exception
	 */
	void deleteType(String typeID) throws Exception;

	void updateType(String typeID, String typeName, String typeDesc, String parentTypeID) throws Exception;

	boolean exists(String typeID);

	Type getType(String typeID) throws Exception;

	Type getParentType(String typeID) throws Exception;

	void refresh() throws Exception;

	/**
	 * 获取某个类型的直接子类型
	 * 
	 * @param typeID
	 * @return
	 */
	Collection<Type> getSubTypes(String typeID);

	/**
	 * 获取某个类型的所有子类型
	 * 
	 * @param typeID
	 * @return
	 */
	Collection<Type> getAllSubTypes(String typeID);
}
